#include <vector>

using namespace std;

/* 二分查找（左闭右开） */
int binarySearch1(vector<int>& nums, int target) {
    int i = 0, j = nums.size();
    while (i < j) {
        int m = (i + j) / 2;
        if (nums[m] < target)
            i = m + 1;
        else if (nums[m] > target)
            j = m;
        else
            return m;
    }
    return -1;
}
